import request from '@/axios'

function formatRequestUri(name) {
  return 'hr/Role/' + name
}
export function get(id: string) {
  return request.get({
    url: formatRequestUri('GetDetailed'),
    params: {
      id
    }
  })
}
export function getSelect() {
  return request.get({
    url: formatRequestUri('GetSelect')
  })
}

export function query(query, paging) {
  return request.post({
    url: formatRequestUri('Query'),
    data: {
      Query: query,
      Index: paging.Index,
      Size: paging.Size,
      SortName: paging.SortName,
      IsDesc: paging.IsDesc
    }
  })
}
export function setIsEnable(id: string, isEnable: boolean) {
  return request.post({
    url: formatRequestUri('SetIsEnable'),
    data: {
      Id: id,
      Value: isEnable
    }
  })
}
export function setIsDefRole(id: string) {
  return request.get({
    url: formatRequestUri('SetIsDefRole'),
    params: {
      id
    }
  })
}
export function deleteRole(id: string) {
  return request.get({
    url: formatRequestUri('Delete'),
    params: {
      id
    }
  })
}

export function add(data) {
  return request.post({
    url: formatRequestUri('Add'),
    data
  })
}
export function set(id: string, data) {
  return request.post({
    url: formatRequestUri('Set'),
    data: {
      Id: id,
      Datum: data
    }
  })
}
export function setIsAdmin(id: string, isAdmin: boolean) {
  return request.post({
    url: formatRequestUri('setIsAdmin'),
    data: {
      Id: id,
      Value: isAdmin
    }
  })
}
